FROM debian:13.2-slim
RUN sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources && \
apt-get -y update && apt-get -y upgrade && \
apt-get install -y wget build-essential libreadline-dev unzip && \
wget -O /usr/local/lua-5.4.8.tar.gz http://www.lua.org/ftp/lua-5.4.8.tar.gz && \
tar zxf /usr/local/lua-5.4.8.tar.gz -C /usr/local/ && \
wget -O /usr/local/luarocks-3.12.2.tar.gz http://luarocks.github.io/luarocks/releases/luarocks-3.12.2.tar.gz && \
tar zxf /usr/local/luarocks-3.12.2.tar.gz -C /usr/local/ && \
# 编译Lua
cd /usr/local/lua-5.4.8 && \
make all test && \
make install && \
#  编译luarocks需要unzip
cd /usr/local/luarocks-3.12.2 && \
./configure --with-lua-include=/usr/local/include && \
make install && \
# 清理
rm -rf /usr/local/lua-5.4.8.tar.gz  /usr/local/lua-5.4.8 && \
rm -rf  /usr/local/luarocks-3.12.2.tar.gz  /usr/local/luarocks-3.12.2 && \
#  执行luarocks install lua-cjson 没有可用的下载工具, 需要安装wget或curl
apt-get purge -y build-essential libreadline-dev && \
rm -rf /var/lib/apt/lists/*
#CMD ["lua", "-v"]

# https://github.com/luarocks/luarocks/wiki/Installation-instructions-for-Unix
# docker build -t registry.cn-hangzhou.aliyuncs.com/xiaoyilin/lua:5.4.8 .
# docker run -it --rm registry.cn-hangzhou.aliyuncs.com/xiaoyilin/lua:5.4.8 bash
# docker push registry.cn-hangzhou.aliyuncs.com/xiaoyilin/lua:5.4.8